package com.djk.daily.thread.threadlocal;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description 两个线程打印日期
 * @Author dujunkai
 * @Date 2021/10/7 10:56
 **/
public class ThreadLocalNormalUsage00 {
    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                String date = new ThreadLocalNormalUsage00().date(10);
                System.out.println(date);
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                String date = new ThreadLocalNormalUsage00().date(100);
                System.out.println(date);
            }
        }).start();
    }

    public String date(int second){
        //参数是毫秒，从1970.1.1 00：00：00 GMT计时,中国是东8区
        Date date = new Date(1000 * second);
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(date);
    }
}
